package com.hexiang.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 异常码
 */
@AllArgsConstructor
@Getter
public enum ResultCodeEnum {
    /**
     * 操作成功
     */
    S200("200", "操作成功", "success"),
    /**
     * 操作失败
     */
    E500("500", "操作失败", "failed"),
    /**
     * 系统错误
     */
    E001("001", "系统错误", "System error"),
    /**
     * 缺少参数
     */
    E015("401", "缺少参数", "Lack of parameter"),
    /**
     * R服务执行异常
     */
    E033("402", "参数校验失败", "validate error");
    /**
     * 编码
     */
    private String code;
    /**
     * msg
     */
    private String msg;
    /**
     * emsg
     */
    private String emsg;

    public static String getMsg(String code) {
        for (ResultCodeEnum c : ResultCodeEnum.values()) {
            if (c.getCode().equalsIgnoreCase(code)) {
                return c.getMsg();
            }
        }
        return null;
    }
}
